package lulin.w09.controller;

import lulin.w09.entity.Teacher;
import lulin.w09.service.TeacherServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/teachers")
public class TeacherController {

    @Autowired
    private TeacherServiceInterface teacherService;

    @PostMapping
    public Long addTeacher(@RequestBody Teacher teacher) {
        return teacherService.addTeacher(teacher);
    }

    @DeleteMapping("/{id}")
    public int deleteTeacher(@PathVariable Long id) {
        return teacherService.deleteTeacher(id);
    }

    @PutMapping
    public int updateTeacher(@RequestBody Teacher teacher) {
        return teacherService.updateTeacher(teacher);
    }

    @GetMapping("/{id}")
    public Teacher getTeacher(@PathVariable Long id) {
        return teacherService.getTeacher(id);
    }

    @GetMapping
    public List<Teacher> getAllTeachers() {
        return teacherService.getAllTeachers();
    }

    @GetMapping("/school/{schoolId}")
    public List<Teacher> getTeachersBySchoolId(@PathVariable Long schoolId) {
        return teacherService.getTeachersBySchoolId(schoolId);
    }

    @GetMapping("/department/{departmentId}")
    public List<Teacher> getTeachersByDepartmentId(@PathVariable Long departmentId) {
        return teacherService.getTeachersByDepartmentId(departmentId);
    }
}    